package cn.edu.xjtu.android.emoji_warfare_android.game.hero;

import java.util.Random;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import cn.edu.xjtu.android.emoji_warfare_android.engine.Debug;
import cn.edu.xjtu.android.emoji_warfare_android.engine.entity.Entity;
import cn.edu.xjtu.android.emoji_warfare_android.engine.entity.Point;
import cn.edu.xjtu.android.emoji_warfare_android.engine.shape.Shape;
import cn.edu.xjtu.android.emoji_warfare_android.game.Config;

/**
 * Hero<br>
 * 角色类<br>
 * 包括玩家、敌人、Boss
 * 
 * @author bill
 *
 */
public class Character extends Entity {
    /**
     * 角色的半径
     */
    public final static float radius = Config.Hero.radius;
    /**
     * 这一个角色的图像
     */
    Bitmap appearance;

    private boolean debug;

    /**
     * 血量
     */
    public int hp;

    /**
     * 等级
     */
    public int level;

    /**
     * 构建一个角色
     * 
     * @param imageIndex
     *            图片index
     */
    public Character(int imageIndex) {
        this(imageIndex, Config.Hero.outline);
    }

    public Character(int imageIndex, Shape outline) {
        super(outline);

        // 设置统一外观
        this.appearance = Config.Hero.image[imageIndex];
    }

    public Character(Shape outline) {
        this(0, outline);
    }

    /**
     * 角色绘制<br>
     */
    @Override
    public boolean onDraw(Canvas canvas) {
        canvas.drawBitmap(appearance, -radius, -radius, Config.Common.bitmapPaint);
        if (debug) {
            Debug.drawCross(canvas, 0, 0);
            Debug.printText(canvas, String.format("(%f, %f)", basePoint.x, basePoint.y));
        }
        return false;
    }

    public Point getBasePoint() {
        return this.basePoint;
    }

    public final static Random mRandom;
    static {
        mRandom = new Random(System.currentTimeMillis());
    }

}
